$(document).ready(function(){
    var username = $('#login-username'),
    password = $('#login-password'),
    loginHelp = $('#login-help');
    $('#loginBtn').click(function(){
        loginHelp.text('');
        var un = $.trim(username.val());
        var pwd = $.trim(password.val());
        var remember = document.getElementById("login-remember").checked
        if(un != '' && un != null && pwd != '' && pwd != null){
            $.ajax({
                type : 'POST',
                url : '/site/login',
                dataType : 'json',
                data : {
                    'username':un,
                    'password':pwd,
                    'remember':remember
                },
                success : function(data){
                    if(data.r == 1){
                        location.replace(data.msg);
                    }else{
                        loginHelp.text(data.msg);
                    }
                }
            })
        }else{
            loginHelp.text("用户名或密码错误");
            return false;
        }
    });
})

